package com.config.sharding.stock.circulation.detail.hint;

import com.config.ShardingDictionaries;
import org.apache.shardingsphere.api.sharding.hint.HintShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.hint.HintShardingValue;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author: create by God of SJF
 * @version: v1.0
 * @description: com.config
 * @date:2021/9/15
 */
@Component
public class StockDetailDBHint extends ShardingDictionaries implements HintShardingAlgorithm<String> {
    @Override
    public Collection<String> doSharding(Collection<String> collection, HintShardingValue<String> hintShardingValue) {
        String a = (String) hintShardingValue.getValues().toArray()[0];
        Collection<String> list = new ArrayList<>();
        a = super.key(a);
        String db = "stock" + a ;
        list.add(db);
        return list;
    }
}
